package Work;
import java.util.Arrays;
import java.util.Scanner;

 abstract class Shape {
	public final static double PI = 3.14;
	public abstract double getPerimeter();
	public abstract double getArea();
}

class Rectangle extends Shape{
	private int width;
	private int length;
	
	public Rectangle (int width, int length){
		this.width = width;
		this.length = length; 
	}
	
	public double getPerimeter(){
		return 2*width+2*length;
	}
	
	public double getArea(){
		return width*length;
	}

	@Override
	public String toString() {
		return "Rectangle [width=" + width + ", length=" + length + "]";
	}
	
}


class Circle extends Shape{
	private int radius;
	
	public Circle(int radius){
		this.radius = radius;
	}
	
	public double getPerimeter(){
		return 2*Shape.PI*radius;
	}
	
	public double getArea(){
		return Shape.PI*radius*radius;
	}

	@Override
	public String toString() {
		return "Circle [radius=" + radius + "]";
	}
	
}




public class Main1 {

	public static double sumAllArea(Shape[] a){
		// TODO Auto-generated method stub
		double sum = 0;
		for (Shape shape : a) {
			sum = sum + shape.getArea();
		}
		return sum;
	}
	
	public static double sumAllPerimeter(Shape[] a){
		double sum = 0;
		for (Shape shape : a) {
			sum = sum + shape.getPerimeter();
		}
		return sum;
	}
	
	public static void Main(String[] args){
		Scanner in = new Scanner(System.in);
		int n = Integer.parseInt(in.nextLine());
		Shape[] S = new Shape[n];
		for (int i = 0; i < S.length; i++) {
			String Line = in.nextLine();
			switch(Line){
			case"rect":
				String[] num = in.nextLine().split(" ");
				Rectangle rect  = new Rectangle(Integer.parseInt(num[0]),Integer.parseInt(num[2]));
				S[i] = rect;
				break;
			
			case"cir":
				
				Circle cir  = new Circle(Integer.parseInt(in.nextLine()));
				S[i] = cir;
				break;
				
			}
			
		}
		System.out.println(sumAllPerimeter(S));
		System.out.println(sumAllArea(S));
		System.out.println(Arrays.toString(S));
		for (Shape shape : S) {
			System.out.printf("%s,%s\n",shape.getClass(),shape.getClass().getSuperclass());
		}
	}
	}


